# 参数计算函数
def cycle_calc(FREQ, Width_4ns, Delay_4ns):
    if FREQ == 0:
        return (0, 0)
    try:
        # 计算周期（纳秒）
        T_ns = (1 / FREQ) * 10**9
        # 计算宽度和延迟（纳秒）
        Width_ns = Width_4ns * 4
        Delay_ns = Delay_4ns * 4
        # 计算空闲时间
        T_idle = Width_ns + Delay_ns
        # 计算100ms和4ns的数量
        if T_idle < T_ns:
            _100ms_num = int((T_ns - T_idle) / (100 * 10**6))
            _4ns_num = int((T_ns - T_idle - _100ms_num * 100 * 10**6) / 4)
        else:
            _100ms_num = 0
            _4ns_num = 0
        return (_100ms_num, _4ns_num)
    except ValueError as e:
        print(f"错误: 参数值错误, FREQ: {FREQ}, Width_4ns: {Width_4ns}, Delay_4ns: {Delay_4ns}, 错误信息: {e}")
        return (0, 0)
    except Exception as e:
        print(f"错误: 未知异常, 错误信息: {e}")
        return (0, 0)

